import Cookies from 'js-cookie'

// const ROLE_KEY = "recruit-user-role";

export function getSessionJson(key) {
    let data = window.sessionStorage.getItem(key);
    if (data === undefined || data === "undefined") {
        return null;
    }
    if (data) {
        return JSON.parse(data);
    }
    return null;
}

export function getLocalStorageJson(key) {
    let data = localStorage.getItem(key);
    if (data === undefined || data === "undefined") {
        return null;
    }
    if (data) {
        return JSON.parse(data);
    }
    return null;
}

export function removeLocalStorageJson(key) {
    localStorage.removeItem(key);
    return null;
}

export function setLocalStorageJson(key, value) {
    localStorage.setItem(key, JSON.stringify(value));
}

export function setSessionJson(key, value) {
    sessionStorage.setItem(key, JSON.stringify(value));
}

export function getSessionValue(key) {
    let data = window.sessionStorage.getItem(key);
    if (data) {
        return data;
    }
    return null;
}


export function setSessionValue(key, value) {
    window.sessionStorage.setItem(key, value);
}

//获取角色信息
/*export function getRole() {
  return localStorage.getItem(ROLE_KEY);
}

//保存角色信息
export function setRole(role) {
  return localStorage.setItem(ROLE_KEY, role);
}*/

//移除用户信息
export function removeSession(key) {
    // localStorage.removeItem(USER_KEY);
    sessionStorage.removeItem(key)
    // localStorage.removeItem(ROLE_KEY);
}
